package com.company;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.SOURCE)
@interface OverrideTest {}

public class Test {
    static int count = 0;
    public int i = 0;
    int j = 3;

    private Test(int i) {
        System.out.println("Test Constructor with Parameters");
    }

    public Test() {
        System.out.println("Test Constructor without Parameters");
    }

    void printI() {
        System.out.println("Test: " + this.i);
    }

    void printJ() {
        System.out.println("Test: " + this.j);
    }
}

class MyTest extends Test {
    int j = 1;

    static int sj = 2;

    public MyTest(int i) {
        j = i;
        System.out.println("MyTest class Constructor");
    }

    public MyTest() {

    }

    /**
     * 类的对象被创建的时候执行
     */
    {
        j = 2;
        MyTest.sj = 3;
        System.out.println("MyTest class Block");
    }

    static {
        String name = "zhangp";
        MyTest.sj = 1;
        sj = 2;
        System.out.println("MyTest class Static block.");
    }

    void printJ(int i) {
        System.out.println("MyTest: " + this.j + this.i);
    }

    static void printJ(float i) {
        System.out.println();
    }

    @OverrideTest
    void printJ (String i) {
        System.out.println("over ride");
    }
}
